<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qwavefrontmesh.cpp -->
  <title>WavefrontMesh QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >WavefrontMesh QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">WavefrontMesh QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$WavefrontMesh-brief -->
<p>The <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a> provides a mesh based on a Wavefront .obj file. <a href="#details">更多...</a></p>
<!-- @@@WavefrontMesh -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import Qt.labs.wavefrontmesh 1.12</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.12</td></tr></table></div><ul>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#lastError-prop">lastError</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneV-prop">projectionPlaneV</a></b></b> : vector3d</li>
<li class="fn"><b><b><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneW-prop">projectionPlaneW</a></b></b> : vector3d</li>
<li class="fn"><b><b><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#source-prop">source</a></b></b> : url</li>
</ul>
<!-- $$$WavefrontMesh-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a> reads the geometry from a Wavefront .obj file and generates a two-dimensional <a href="qsggeometry.html">geometry</a> from this. If the .obj file contains a three-dimensional shape, it will be orthographically projected, onto a plane. If defined, this is given by <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneV-prop">projectionPlaneV</a> and <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneW-prop">projectionPlaneW</a>. Otherwise, the first face encountered in the data will be used to determine the projection plane.</p>
<p>If the file contains texture coordinates, these will also be used. Otherwise, the vertexes of the object will be normalized and used.</p>
<p>The mesh can be used in a <a href="qml-qtquick-shadereffect.html">ShaderEffect</a> to define the shaded geometry. The geometry will be normalized before use, so the position and scale of the input objects have no impact on the result.</p>
<p><b>Note: </b>Some Wavefront exporters will change the source scene's coordinate system before exporting it. This can cause unexpected results when Qt applies the projection. If the visual results are not as you expect, try checking the export parameters and the documentation of the editor tool to see if this is the case.</p><p>For instance, the following example takes an .obj file containing a standard torus and visualizes the automatically generated texture coordinates.</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/qtlabs-wavefrontmesh.png" alt="" /></p></td><td ><pre class="qml">

  import QtQuick 2.\1
  import Qt.labs.wavefrontmesh 1.\1

  ShaderEffect {
      width: 200
      height: 200
      mesh: WavefrontMesh {
          source: &quot;torus.obj&quot;
          projectionPlaneV: Qt.vector3d(0, 1, 0)
          projectionPlaneW: Qt.vector3d(1, 0, 0)
      }
      vertexShader: &quot;
              uniform highp mat4 qt_Matrix;
              attribute highp vec4 qt_Vertex;
              attribute highp vec2 qt_MultiTexCoord0;
              varying highp vec2 coord;
              void main() {
                  coord = qt_MultiTexCoord0;
                  gl_Position = qt_Matrix * qt_Vertex;
              }&quot;
      fragmentShader: &quot;
              varying highp vec2 coord;
              uniform lowp float qt_Opacity;
              void main() {
                  gl_FragColor = vec4(coord.x, coord.y, 0.0, 1.0);
              }&quot;

  }

</pre>
</td></tr>
</table></div>
<p><b>Note: </b>Since the input is a 3D torus, we need to define the projection plane. This would not be necessary when using a 2D shape as input. We use the XY plane in this case, because of the orientation of the input.</p><!-- @@@WavefrontMesh -->
<h2>属性文档</h2>
<!-- $$$lastError -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="lastError-prop">
<td class="tblQmlPropNode"><p>
<a name="lastError-prop"></a><span class="name">lastError</span> : <span class="type"><a href="../qtqml/qml-enumeration.html">enumeration</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the last error, if any, that occurred when parsing the source or building the mesh.</p>
<ul>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.NoError No error has occurred.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.InvalidSourceError The source was not recognized as a valid .obj file.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.UnsupportedFaceShapeError The faces in the source is of an unsupported type. <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a> only supports triangles and convex quads.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.UnsupportedIndexSizeError The source shape is too large. Only 16 bit indexes are supported.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.FileNotFoundError The source file was not found.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.MissingPositionAttributeError The 'qt_Vertex' attribute is missing from the shaders.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.MissingTextureCoordinateAttributeError The texture coordinate attribute in the shaders is wrongly named. Use 'qt_MultiTexCoord0'.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.MissingPositionAndTextureCoordinateAttributesError Both the 'qt_Vertex' and 'qt_MultiTexCoord0' attributes are missing from the shaders.</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.TooManyAttributesError The shaders expect too many attributes (maximum is two: Position, 'qt_Vertex', and texture coordinate, 'qt_MultiTexCoord0').</li>
<li><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a>.InvalidPlaneDefinitionError The V and W vectors in the plane cannot be null, nor parallel to each other.</li>
</ul>
</div></div><!-- @@@lastError -->
<br/>
<!-- $$$projectionPlaneV -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="projectionPlaneV-prop">
<td class="tblQmlPropNode"><p>
<a name="projectionPlaneV-prop"></a><span class="name">projectionPlaneV</span> : <span class="type"><a href="qml-vector3d.html">vector3d</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.</p>
<p>This will be done in <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a> by an orthographic projection onto an appropriate plane.</p>
<p>The projectionPlaneV is one of two vectors in the plane in 3D space. If either this, or <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneW-prop">projectionPlaneW</a> is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.</p>
<p><b>Note: </b>projectionPlaneV and <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneW-prop">projectionPlaneW</a> cannot be parallel vectors.</p></div></div><!-- @@@projectionPlaneV -->
<br/>
<!-- $$$projectionPlaneW -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="projectionPlaneW-prop">
<td class="tblQmlPropNode"><p>
<a name="projectionPlaneW-prop"></a><span class="name">projectionPlaneW</span> : <span class="type"><a href="qml-vector3d.html">vector3d</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Since the Wavefront .obj format describes an object in 3D space, the coordinates have to be projected into 2D before they can be displayed in Qt Quick.</p>
<p>This will be done in <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html">WavefrontMesh</a> by an orthographic projection onto an appropriate plane.</p>
<p>The projectionPlaneW is one of two vectors in the plane in 3D space. If either this, or <a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneV-prop">projectionPlaneV</a> is set to (0, 0, 0) (the default), then the plane will be detected based on the first encountered face in the data set.</p>
<p><b>Note: </b><a href="qml-qt-labs-wavefrontmesh-wavefrontmesh.html#projectionPlaneV-prop">projectionPlaneV</a> and projectionPlaneW cannot be parallel vectors.</p></div></div><!-- @@@projectionPlaneW -->
<br/>
<!-- $$$source -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="source-prop">
<td class="tblQmlPropNode"><p>
<a name="source-prop"></a><span class="name">source</span> : <span class="type"><a href="../qtqml/qml-url.html">url</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the URL of the source. This must be either a local file or in qrc. The source will be read as a Wavefront .obj file and the geometry will be updated.</p>
</div></div><!-- @@@source -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
